package leetcode;

/**
 * @Project : algorithm-learning-java
 * @Package : leetcode
 * @Author : Ruoyu Wang
 * @User : Momenta
 * @DateTime : 2024/1/9 15:03
 */
public class Q0053 {
    public int maxSubArray(int[] nums) {
        int tmp = nums[0];
        int res = nums[0];
        for (int i = 1; i < nums.length; i++) {
            tmp = nums[i] + Math.max(tmp, 0);
            res = Math.max(res, tmp);
        }
        return res;
    }
}
